const Collect = require('../model/Collect')
const Article = require('../model/Article')
const Reading = require('../model/Reading')
const User = require('../model/User')
const Image = require('../model/Image')

async function getUserInfo(user) {
    if (!user) {
        return false
    }
    let author = (await User.findOne({
        where: {
            account: user
        }
    })).dataValues;
    image = (await Image.findOne({
        where: {
            id: author.portraitId
        }
    })).dataValues;
    let username = author.username;
    let userId = author.userId;
    let imageUrl = image.thumbPath;
    let info = {
        statusMag: {
            username,
            userId,
            imageUrl
        },
        statusCode: 1
    };
    return info
}

module.exports = getUserInfo